﻿using MeasureAbstract.Base;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using 紧缩场反射面装调测试系统.ViewModels;

namespace 紧缩场反射面装调测试系统.Views
{
    /// <summary>
    /// VectorNetworkAnalyzer.xaml 的交互逻辑
    /// </summary>
    public partial class InstrumentSetup : UserControl
    {
        public static InstrumentSetupViewModel ViewModel = new InstrumentSetupViewModel();
        public InstrumentSetup()
        {
            InitializeComponent();
            this.DataContext = ViewModel;
        }

        private void TreeViewItem_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)

        {

            e.Handled = true;

        }
    }

    public class NullToCollapsed : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return Visibility.Collapsed;
            }
            else
            {
                if (parameter == null)
                {
                    return Visibility.Collapsed;
                }
                string para = parameter.ToString();
                var temp = (IEnumerable<dynamic>)value;
                //var temp=(ObservableCollection<IDeviceBase>)value;
                if (temp.Count() >= int.Parse(para) + 1)
                {
                    return Visibility.Visible;
                }
                else
                {
                    return Visibility.Collapsed;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
